<!DOCTYPE html>
<!--********************************************-->
<!--*       Generated from PreTeXt source      *-->
<!--*                                          *-->
<!--*         https://pretextbook.org          *-->
<!--*                                          *-->
<!--********************************************-->
<html lang="en-US">
<head xmlns:og="http://ogp.me/ns#" xmlns:book="https://ogp.me/ns/book#">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Fourier Series</title>
<meta name="Keywords" content="Authored in PreTeXt">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:type" content="book">
<meta property="book:title" content="MATH 2023: Ordinary and Partial Differential Equations">
<meta property="book:author" content="Xiaoyi Chen and Wei Zhang">
<script src="https://sagecell.sagemath.org/static/embedded_sagecell.js"></script><script>window.MathJax = {
  tex: {
    inlineMath: [['\\(','\\)']],
    tags: "none",
    tagSide: "right",
    tagIndent: ".8em",
    packages: {'[+]': ['base', 'extpfeil', 'ams', 'amscd', 'newcommand', 'knowl']}
  },
  options: {
    ignoreHtmlClass: "tex2jax_ignore|ignore-math",
    processHtmlClass: "process-math",
    renderActions: {
        findScript: [10, function (doc) {
            document.querySelectorAll('script[type^="math/tex"]').forEach(function(node) {
                var display = !!node.type.match(/; *mode=display/);
                var math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
                var text = document.createTextNode('');
                node.parentNode.replaceChild(text, node);
                math.start = {node: text, delim: '', n: 0};
                math.end = {node: text, delim: '', n: 0};
                doc.math.push(math);
            });
        }, '']
    },
  },
  chtml: {
    scale: 0.88,
    mtextInheritFont: true
  },
  loader: {
    load: ['input/asciimath', '[tex]/extpfeil', '[tex]/amscd', '[tex]/newcommand', '[pretext]/mathjaxknowl3.js'],
    paths: {pretext: "https://pretextbook.org/js/lib"},
  },
startup: {
    pageReady() {
      return MathJax.startup.defaultPageReady().then(function () {
      console.log("in ready function");
      $(document).trigger("runestone:mathjax-ready");
      }
    )}
},
};
</script><script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script><script src="https://pretextbook.org/js/lib/jquery.min.js"></script><script src="https://pretextbook.org/js/lib/jquery.sticky.js"></script><script src="https://pretextbook.org/js/lib/jquery.espy.min.js"></script><script src="https://pretextbook.org/js/0.13/pretext.js"></script><script>miniversion=0.674</script><script src="https://pretextbook.org/js/0.13/pretext_add_on.js?x=1"></script><script src="https://pretextbook.org/js/lib/knowl.js"></script><!--knowl.js code controls Sage Cells within knowls--><script>sagecellEvalName='Evaluate (Sage)';
</script><link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700&amp;subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/pretext.css" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/pretext_add_on.css" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/banner_default.css" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/toc_default.css" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/knowls_default.css" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/style_default.css" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/colors_blue_red.css" rel="stylesheet" type="text/css">
<link href="https://pretextbook.org/css/0.4/setcolors.css" rel="stylesheet" type="text/css">
</head>
<body class="pretext-book ignore-math has-toc has-sidebar-left">
<a class="assistive" href="#content">Skip to main content</a><div id="latex-macros" class="hidden-content process-math" style="display:none"><span class="process-math">\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\newcommand{\lt}{&lt;}
\newcommand{\gt}{&gt;}
\newcommand{\amp}{&amp;}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle     \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle        \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle      \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)</span></div>
<header id="masthead" class="smallbuttons"><div class="banner"><div class="container">
<a id="logo-link" href=""></a><div class="title-container">
<h1 class="heading"><a href="MATH-2023-OPDE.html"><span class="title">MATH 2023: Ordinary and Partial Differential Equations</span></a></h1>
<p class="byline">Xiaoyi Chen and Wei Zhang</p>
</div>
</div></div>
<nav id="primary-navbar" class="navbar"><div class="container">
<div class="navbar-top-buttons">
<button class="sidebar-left-toggle-button button active" aria-label="Show or hide table of contents sidebar">Contents</button><div class="tree-nav toolbar toolbar-divisor-3">
<a class="index-button toolbar-item button" href="index-1.html" title="Index">Index</a><span class="threebuttons"><a id="previousbutton" class="previous-button toolbar-item button" href="sec7_2.html" title="Previous">Prev</a><a id="upbutton" class="up-button button toolbar-item" href="ch_seven.html" title="Up">Up</a><a id="nextbutton" class="next-button button toolbar-item" href="sec7_4.html" title="Next">Next</a></span>
</div>
</div>
<div class="navbar-bottom-buttons toolbar toolbar-divisor-4">
<button class="sidebar-left-toggle-button button toolbar-item active">Contents</button><a class="previous-button toolbar-item button" href="sec7_2.html" title="Previous">Prev</a><a class="up-button button toolbar-item" href="ch_seven.html" title="Up">Up</a><a class="next-button button toolbar-item" href="sec7_4.html" title="Next">Next</a>
</div>
</div></nav></header><div class="page">
<div id="sidebar-left" class="sidebar" role="navigation"><div class="sidebar-content">
<nav id="toc"><ul>
<li class="link frontmatter"><a href="meta_frontmatter.html" data-scroll="meta_frontmatter" class="internal"><span class="title">Front Matter</span></a></li>
<li class="link">
<a href="ch_first.html" data-scroll="ch_first" class="internal"><span class="codenumber">1</span> <span class="title">Introduction</span></a><ul>
<li><a href="sec_1-intro.html" data-scroll="sec_1-intro" class="internal">Classification of Differential Equations</a></li>
<li><a href="sec_2-intro.html" data-scroll="sec_2-intro" class="internal">Linear and Nonlinear Equation</a></li>
<li><a href="sec_3-intro.html" data-scroll="sec_3-intro" class="internal">Geometrical Aspect</a></li>
<li><a href="sec_4-intro.html" data-scroll="sec_4-intro" class="internal">Motivation</a></li>
</ul>
</li>
<li class="link">
<a href="ch_second.html" data-scroll="ch_second" class="internal"><span class="codenumber">2</span> <span class="title">First Order Ordinary Differential Equations</span></a><ul>
<li><a href="sec2_1.html" data-scroll="sec2_1" class="internal">Linear Equations</a></li>
<li><a href="sec2_2.html" data-scroll="sec2_2" class="internal">Further Discussion of Linear Equations (For reading only)</a></li>
<li><a href="sec2_3.html" data-scroll="sec2_3" class="internal">Separable Equations</a></li>
<li><a href="sec2_4.html" data-scroll="sec2_4" class="internal">Difference Between Linear and Nonlinear Equations</a></li>
<li><a href="sec2_5.html" data-scroll="sec2_5" class="internal">Applications of modeling with first order ODE(For reading only)</a></li>
<li><a href="sec2_6.html" data-scroll="sec2_6" class="internal">Exact Equations and Integrating Factors</a></li>
</ul>
</li>
<li class="link">
<a href="ch_third.html" data-scroll="ch_third" class="internal"><span class="codenumber">3</span> <span class="title">third Order Linear Equations</span></a><ul>
<li><a href="sec3_1.html" data-scroll="sec3_1" class="internal">Homogeneous equations with constant coefficient</a></li>
<li><a href="sec3_2.html" data-scroll="sec3_2" class="internal">Fundamental Solutions of Linear Homogeneous Equations</a></li>
<li><a href="sec3_3.html" data-scroll="sec3_3" class="internal">Linear Independence and Wronskian</a></li>
<li><a href="sec3_4.html" data-scroll="sec3_4" class="internal">Complex roots of the characteristic equations</a></li>
<li><a href="sec3_5.html" data-scroll="sec3_5" class="internal">Repeated Roots: Reduction of Order</a></li>
<li><a href="sec3_6.html" data-scroll="sec3_6" class="internal">Non-homogeneous Equations and Method of Undetermined Coefficients</a></li>
<li><a href="sec3_7.html" data-scroll="sec3_7" class="internal">Variation of Parameters</a></li>
</ul>
</li>
<li class="link">
<a href="ch_four.html" data-scroll="ch_four" class="internal"><span class="codenumber">4</span> <span class="title">Higher Order Linear Equations</span></a><ul>
<li><a href="sec4_1.html" data-scroll="sec4_1" class="internal">General Theory of the <span class="process-math">\(n\)</span>-th Order Linear Equations</a></li>
<li><a href="sec4_2.html" data-scroll="sec4_2" class="internal">Homogeneous Equations with Constant Coefficients</a></li>
<li><a href="sec4_3.html" data-scroll="sec4_3" class="internal">The Method of Undetermined Coefficients</a></li>
<li><a href="sec4_4.html" data-scroll="sec4_4" class="internal">The Method of Variation of Parameters</a></li>
</ul>
</li>
<li class="link">
<a href="ch_five.html" data-scroll="ch_five" class="internal"><span class="codenumber">5</span> <span class="title">Series Solutions of Second Order Linear Equations</span></a><ul>
<li><a href="sec5_1.html" data-scroll="sec5_1" class="internal">Brief Review on Power Series</a></li>
<li><a href="sec5_2.html" data-scroll="sec5_2" class="internal">Introduction</a></li>
<li><a href="sec5_3.html" data-scroll="sec5_3" class="internal">Series Solutions Near an Ordinary Point</a></li>
<li><a href="sec5_4.html" data-scroll="sec5_4" class="internal">Euler’s Equation</a></li>
<li><a href="sec5_5.html" data-scroll="sec5_5" class="internal">Series Solution near a Regular Singular Point</a></li>
</ul>
</li>
<li class="link">
<a href="ch_six.html" data-scroll="ch_six" class="internal"><span class="codenumber">6</span> <span class="title">System of First Order Linear Equations</span></a><ul>
<li><a href="sec6_1.html" data-scroll="sec6_1" class="internal">Introduction <span class="process-math">\(\&amp;\)</span> Basic Theory</a></li>
<li><a href="sec6_2.html" data-scroll="sec6_2" class="internal">Homogeneous System with Constant Coefficients</a></li>
<li><a href="sec6_3.html" data-scroll="sec6_3" class="internal">Complex Eigenvalues</a></li>
<li><a href="sec6_4.html" data-scroll="sec6_4" class="internal">Repeated Eigenvalues</a></li>
<li><a href="sec6_5.html" data-scroll="sec6_5" class="internal">Fundamental Matrices</a></li>
<li><a href="sec6_6.html" data-scroll="sec6_6" class="internal">Non-homogeneous linear systems</a></li>
</ul>
</li>
<li class="link">
<a href="ch_seven.html" data-scroll="ch_seven" class="internal"><span class="codenumber">7</span> <span class="title">Partial Differential Equations</span></a><ul>
<li><a href="sec7_1.html" data-scroll="sec7_1" class="internal">Two-Point Boundary Value Problems</a></li>
<li><a href="sec7_2.html" data-scroll="sec7_2" class="internal">Eigenvalue Problems</a></li>
<li><a href="sec7_3.html" data-scroll="sec7_3" class="active">Fourier Series</a></li>
<li><a href="sec7_4.html" data-scroll="sec7_4" class="internal">The Fourier Convergence Theorem</a></li>
<li><a href="sec7_5.html" data-scroll="sec7_5" class="internal">Even and Odd Functions</a></li>
<li><a href="sec7_6.html" data-scroll="sec7_6" class="internal">Introduction to Partial Differential Equations</a></li>
<li><a href="sec7_7.html" data-scroll="sec7_7" class="internal">1D Heat Equation; Solutions by Separation of Variable and Fourier Series</a></li>
<li><a href="sec7_8.html" data-scroll="sec7_8" class="internal">Other Heat Conduction Problems</a></li>
</ul>
</li>
<li class="link">
<a href="ch_eight.html" data-scroll="ch_eight" class="internal"><span class="codenumber">8</span> <span class="title">Laplace transform</span></a><ul>
<li><a href="sec8_1.html" data-scroll="sec8_1" class="internal">What are Laplace Transforms, and Why?</a></li>
<li><a href="sec8_2.html" data-scroll="sec8_2" class="internal">Finding Laplace Transforms</a></li>
<li><a href="sec8_3.html" data-scroll="sec8_3" class="internal">Finding inverse transforms using partial fractions</a></li>
<li><a href="sec8_4.html" data-scroll="sec8_4" class="internal">Solving ODEs and ODE Systems</a></li>
<li><a href="sec8_5.html" data-scroll="sec8_5" class="internal">Step input and Impulse problems</a></li>
<li><a href="sec8_6.html" data-scroll="sec8_6" class="internal">Laplace transform for PDE (heat equation)</a></li>
</ul>
</li>
<li class="link">
<a href="ch_features.html" data-scroll="ch_features" class="internal"><span class="codenumber">9</span> <span class="title">Examples of PreTeXt features</span></a><ul><li><a href="sec_features-blocks.html" data-scroll="sec_features-blocks" class="internal">Environments and Blocks</a></li></ul>
</li>
<li class="link backmatter"><a href="meta_backmatter.html" data-scroll="meta_backmatter" class="internal"><span class="title">Backmatter</span></a></li>
<li class="link"><a href="solutions-1.html" data-scroll="solutions-1" class="internal"><span class="codenumber">A</span> <span class="title">Selected Hints</span></a></li>
<li class="link"><a href="solutions-2.html" data-scroll="solutions-2" class="internal"><span class="codenumber">B</span> <span class="title">Selected Solutions</span></a></li>
<li class="link"><a href="appendix-1.html" data-scroll="appendix-1" class="internal"><span class="codenumber">C</span> <span class="title">List of Symbols</span></a></li>
<li class="link"><a href="index-1.html" data-scroll="index-1" class="internal"><span class="title">Index</span></a></li>
<li class="link"><a href="colophon-1.html" data-scroll="colophon-1" class="internal"><span class="title">Colophon</span></a></li>
</ul></nav><div class="extras"><nav><a class="pretext-link" href="https://pretextbook.org">Authored in PreTeXt</a><a href="https://www.mathjax.org"><img title="Powered by MathJax" src="https://www.mathjax.org/badge/badge.gif" alt="Powered by MathJax"></a></nav></div>
</div></div>
<main class="main"><div id="content" class="pretext-content"><section class="section" id="sec7_3"><h2 class="heading hide-type">
<span class="type">Section</span> <span class="codenumber">7.3</span> <span class="title">Fourier Series</span>
</h2>
<p id="p-338">The solutions to many important problems involving partial differential equations can be expressed as an infinite sum of sines and/or cosines. In this and the following two sections we explain in detail how this can be done. These trigonometric series are called <dfn class="terminology">Fourier series</dfn>; they are somewhat analogous to Taylor series in that both types of series provide a means of expressing quite complicated functions in terms of certain familiar elementary functions.</p>
<p id="p-339">Representing <dfn class="terminology">periodic</dfn> functions as a series of sine and cosine functions.<dfn class="terminology">Definition</dfn> A function <span class="process-math">\(f(x)\)</span> is <dfn class="terminology">periodic</dfn> with period <span class="process-math">\(T\text{,}\)</span> if</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
f(x+T)=f(x),\quad \forall x
\end{equation*}
</div>
<p class="continuation">Note: If <span class="process-math">\(T\)</span> is a period, so are <span class="process-math">\(2T, 3T, \cdots\text{.}\)</span>The smallest period <span class="process-math">\(T\)</span> is called the <dfn class="terminology">fundamental period</dfn>.<dfn class="terminology">Properties:</dfn> If <span class="process-math">\(f(x)\)</span> and <span class="process-math">\(g(x)\)</span> are both periodic with period <span class="process-math">\(T\text{,}\)</span> so will any linear combination <span class="process-math">\(af(x) + bg(x)\)</span> for <span class="process-math">\(a, b\in\mathbb{R}\text{;}\)</span> Also, the product <span class="process-math">\(f(x)g(x)\)</span> is periodic with the same period <span class="process-math">\(T\text{.}\)</span>Known examples of periodic functions: trig functions.With period <span class="process-math">\(2\pi\text{:}\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\sin x, \sin 2x, \sin 3x, \cdots ,\cos x, \cos2x, \cos3x,\cdots
\end{equation*}
</div>
<p class="continuation">With period <span class="process-math">\({2L}\text{:}\)</span>  (<span class="process-math">\(L&gt;0\)</span>)</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\sin \frac{\pi x}{L}, \sin \frac{2\pi x}{L}, \sin \frac{3\pi x}{L}, \cdots, \cos \frac{\pi x}{L}, \cos \frac{2\pi x}{L}, \cos \frac{3\pi x}{L}, \cdots
\end{equation*}
</div>
<p class="continuation">We have the <dfn class="terminology">trig set</dfn>:</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\left\{1, \sin \frac{m\pi x}{L}, \cos \frac{m\pi x}{L}\right\},\qquad m=1,2,\cdots
\end{equation*}
</div>
<p class="continuation"><dfn class="terminology">Definition</dfn> Let <span class="process-math">\(f(x)\)</span> be periodic with period <span class="process-math">\(2L\text{.}\)</span> <dfn class="terminology">Fourier series</dfn> for <span class="process-math">\(f(x)\)</span> is:</p>
<div class="displaymath process-math" data-contains-math-knowls="" id="fourier">
\begin{equation}
\hat{f}(x)=\frac{a_0}{2}+\sum_{m=1}^{\infty}\left(a_m\cos\frac{m\pi x}{L} +b_m\sin\frac{m\pi x}{L}\right)\tag{7.3.1}
\end{equation}
</div>
<p class="continuation">Here the constants <span class="process-math">\(a_0\text{,}\)</span> <span class="process-math">\(a_m\text{,}\)</span> <span class="process-math">\(b_m\)</span> are called: <dfn class="terminology">Fourier coefficients</dfn>.</p>
<p id="p-340">How to compute the Fourier coefficients? Use the orthogonality of the trig set!<dfn class="terminology">Definition</dfn> Given two functions <span class="process-math">\(u(x)\text{,}\)</span> <span class="process-math">\(v(x)\in C[a,b]\text{,}\)</span> define the <dfn class="terminology">inner product</dfn> on <span class="process-math">\(C[a,b]\)</span> as</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
&lt;u,v&gt;:=\int_a^b u(x) v(x)~\textrm{d}x.
\end{equation*}
</div>
<p class="continuation">In our case, <span class="process-math">\(a = -L\text{,}\)</span> <span class="process-math">\(b = L\)</span> (period <span class="process-math">\(2L\)</span>), i.e.,</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
&lt;u,v&gt;:=\int_{-L}^{L} u(x) v(x)~\textrm{d}x.
\end{equation*}
</div>
<p class="continuation"><dfn class="terminology">Definition</dfn> The functions <span class="process-math">\(u(x)\)</span> and <span class="process-math">\(v(x)\)</span> are <dfn class="terminology">orthogonal</dfn> if <span class="process-math">\(&lt;u, v&gt; = 0\text{.}\)</span><dfn class="terminology">Claim 1:</dfn> The trig set is <em class="emphasis">mutually orthogonal</em>, i.e, any two distinct functions in the set are orthogonal to each other. This means</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\begin{aligned}
&lt;1,\sin \frac{m\pi x}{L}&gt;=0, \qquad &lt;1,\cos \frac{m\pi x}{L}&gt;=0,&amp; &amp; \forall m\\
&lt;\sin \frac{m\pi x}{L}, \sin \frac{n\pi x}{L}&gt;=0,  \quad &lt;\cos \frac{m\pi x}{L}, \cos \frac{n\pi x}{L}&gt;=0,&amp; &amp; \forall m\neq n\\
&lt;\sin \frac{m\pi x}{L}, \cos \frac{n\pi x}{L}&gt;=0,&amp; &amp; \forall m,n
\end{aligned}
\end{equation*}
</div>
<p class="continuation"><dfn class="terminology">Proof.</dfn> Check the inner product by direct integration:</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\int_{-L}^{L} \sin \frac{m\pi x}{L} \textrm{d}x =0, \quad \int_{-L}^{L} \cos \frac{m\pi x}{L} \textrm{d}x =0,~~~\forall m
\end{equation*}
</div>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\int_{-L}^{L} \sin \frac{m\pi x}{L}\sin \frac{n\pi x}{L} \textrm{d}x=\frac{1}{2}\int_{-L}^{L} \left[\cos\frac{(m-n)\pi x}{L} -\cos\frac{(m+n)\pi x}{L}\right] \textrm{d}x =0,~~\forall m\neq n.
\end{equation*}
</div>
<p class="continuation">All other identities can be proven in a similar way.<dfn class="terminology">Claim 2:</dfn> The inner product of any two equal functions in the trig set equals some constants, that is,</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
&lt;1,1&gt;=2L,
\end{equation*}
</div>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
&lt;\sin \frac{n\pi x}{L}, \sin \frac{n\pi x}{L}&gt;=L,  \qquad &lt;\cos \frac{n\pi x}{L}, \cos \frac{n\pi x}{L}&gt;=L, \quad \forall n
\end{equation*}
</div>
<p class="continuation"><dfn class="terminology">Proof.</dfn> Direct integration gives</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\int_{-L}^{L} \sin^2 \frac{n\pi x}{L} \textrm{d}x=\frac{1}{2}\int_{-L}^{L} \left[1 -\cos\frac{2n\pi x}{L}\right] \textrm{d}x =L.
\end{equation*}
</div>
<p class="continuation">We omit the proof for the other identities.</p>
<p id="p-341">Back to Fourier series.For <span class="process-math">\(f(x)\)</span> periodic with period <span class="process-math">\(2L\text{,}\)</span> Fourier series for <span class="process-math">\(f(x)\)</span> is defined as:</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\hat{f}(x)=\frac{a_0}{2}+\sum_{m=1}^{\infty}\left(a_m\cos\frac{m\pi x}{L} +b_m\sin\frac{m\pi x}{L}\right),\quad (*)
\end{equation*}
</div>
<p class="continuation">To determine <span class="process-math">\(a_i\)</span> and <span class="process-math">\(b_i\text{,}\)</span> we use the <dfn class="terminology">orthogonality</dfn> of the trig set!<dfn class="terminology">Steps:</dfn> Multiply <span class="process-math">\((*)\)</span> by <span class="process-math">\(\cos\frac{n\pi x}{L}\)</span> and integrate over <span class="process-math">\([-L, L]\text{.}\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\begin{aligned}\int_{-L}^L f(x)\cos\frac{n\pi x}{L} &amp;=&amp; \int_{-L}^L \frac{a_0}{2}\cos\frac{n\pi x}{L}+\sum_{m=1}^{\infty}\int_{-L}^L a_m\cos\frac{m\pi x}{L}\cos\frac{n\pi x}{L}\textrm{d}x\\
&amp; &amp; +\sum_{m=1}^{\infty}\int_{-L}^Lb_m\sin\frac{m\pi x}{L}\cos\frac{n\pi x}{L}\textrm{d}x.\end{aligned}
\end{equation*}
</div>
<p class="continuation">All the terms are <span class="process-math">\(0\)</span> except one:</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\int_{-L}^L f(x)\cos\frac{n\pi x}{L} = \int_{-L}^L a_n\cos\frac{n\pi x}{L}\cos\frac{n\pi x}{L}\textrm{d}x=a_nL
\end{equation*}
</div>
<p class="continuation">This gives us the formula to compute <span class="process-math">\(a_n\text{:}\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
{a_n=\frac{1}{L}\int_{-L}^L f(x)\cos\frac{n\pi x}{L}\textrm{d}x},\qquad n=1,2,3,\cdots
\end{equation*}
</div>
<p class="continuation">Similarly, multiplying <span class="process-math">\((*)\)</span> by <span class="process-math">\(\sin\frac{n\pi x}{L}\)</span> and integrating over <span class="process-math">\([-L, L]\text{,}\)</span> we derive the formula for <span class="process-math">\(b_n\text{:}\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
{b_n=\frac{1}{L}\int_{-L}^L f(x)\sin\frac{n\pi x}{L}\textrm{d}x},\qquad n=1,2,3,\cdots
\end{equation*}
</div>
<p class="continuation">In a similar way, we get</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
{a_0=\frac{1}{L}\int_{-L}^L f(x)\textrm{d}x}.
\end{equation*}
</div>
<p class="continuation">Note that <span class="process-math">\(a_0/2\)</span> is the average of <span class="process-math">\(f(x)\)</span> over a period. The formula for <span class="process-math">\(a_0\)</span> fit in the one for <span class="process-math">\(a_n\)</span> with <span class="process-math">\(n = 0\text{.}\)</span> Hence we summarize the formulae in a more compacted way. These formulae for computing the Fourier coefficients are called <dfn class="terminology">Euler-Fourier formula</dfn>. If the period is <span class="process-math">\(2\pi\text{,}\)</span> i.e., <span class="process-math">\(2L = 2\pi\text{,}\)</span> we get simpler looking formulas</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
a_n=\frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos nx\textrm{d}x,\qquad n=\textcolor{red}{0},1,2,3,\cdots
\end{equation*}
</div>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
b_n=\frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\sin nx\textrm{d}x,\qquad n=1,2,3,\cdots.
\end{equation*}
</div>
<p id="p-342">Find the Fourier series for a periodic function <span class="process-math">\(f(x)\)</span> with period <span class="process-math">\(2\pi\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
f(x)=\left\{\begin{array}{rl}-1, &amp; \text{if~} -\pi&lt;x&lt;0\\
1,  &amp; \text{if~} 0&lt;x&lt;\pi\end{array}\right.,\qquad f(x+2\pi)=f(x).
\end{equation*}
</div>
<p class="continuation"><dfn class="terminology">Solution:</dfn> We use the Euler-Fourier formulas with <span class="process-math">\(L = \pi\text{:}\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
a_0=\frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \textrm{d}x=\frac{1}{\pi}\left[\int_{-\pi}^{0} -1 \textrm{d}x + \int_{0}^{\pi} 1 \textrm{d}x\right].
\end{equation*}
</div>
<p class="continuation">(Or note that <span class="process-math">\(f (x)\)</span> is an odd function. While integrating over a period, one get 0.)For <span class="process-math">\(n \geq 1\text{,}\)</span> we have</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\begin{aligned} a_n &amp;= \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos nx\textrm{d}x\\
&amp;= \frac{1}{\pi}\int_{-\pi}^{0} -\cos nx \textrm{d}x + \frac{1}{\pi}\int_{0}^{\pi} \cos nx \textrm{d}x\\
&amp;= \frac{1}{\pi}(-\frac{1}{n})\sin nx|_{x=-\pi}^0 + \frac{1}{\pi}\frac{1}{n}\sin nx|_{0}^{\pi}=0.\end{aligned}
\end{equation*}
</div>
<p class="continuation">(Or, <span class="process-math">\(f(x)\)</span> is odd, and <span class="process-math">\(\cos nx\)</span> is even. Then, the product <span class="process-math">\(f (x) \cos nx\)</span> is odd. The integral over an entire period is 0.)Finally, we compute <span class="process-math">\(b_n\)</span> as</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\begin{aligned} b_n &amp;= \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\sin nx\textrm{d}x\\
&amp;= \frac{1}{\pi}\int_{-\pi}^{0} -\sin nx \textrm{d}x + \frac{1}{\pi}\int_{0}^{\pi} \sin nx \textrm{d}x\\
&amp;= -\frac{1}{\pi n}(-\cos nx)|_{x=-\pi}^0 + \frac{1}{\pi n}(-\cos nx)|_{0}^{\pi}\\
%                 &amp;= -\frac{1}{\pi n}(-1+\cos(-n\pi))+ \frac{1}{\pi n}(-\cos n\pi +1)\\
&amp;= \frac{2}{n\pi}(1-\cos n\pi).\end{aligned}
\end{equation*}
</div>
<p class="continuation">(Or, <span class="process-math">\(\sin nx\)</span> is odd, so <span class="process-math">\(f(x)\sin nx\)</span> is even. The integrals on <span class="process-math">\([-\pi,0]\)</span> and <span class="process-math">\([0,\pi]\)</span> are the same. So one needs to do only one integral, and multiply the result by 2.)Then</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
b_n=\frac{2}{n\pi}(1-(-1)^n)=\left\{\begin{array}{rl}\frac{4}{n\pi},\qquad n \text{ odd},\\
0, \qquad n\text{ even}.\end{array}\right.
\end{equation*}
</div>
<p class="continuation">Since all <span class="process-math">\(a_n's\)</span> are 0 and <span class="process-math">\(b_n\)</span> is nonzero only for odd <span class="process-math">\(n\text{,}\)</span> we will only have sine functions. We can now write out the Fourier series with the first few terms.</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\hat{f}(x)=\frac{4}{\pi}\left[\sin x+\frac{1}{3}\sin 3x +\frac{1}{5}\sin 5x +\frac{1}{7} \sin 7x+\cdots\right].
\end{equation*}
</div>
<p class="continuation"><dfn class="terminology">Partial sum of a series:</dfn> The sum of the first few terms, while truncating the rest.We can write <span class="process-math">\(y_n(x)\)</span> to be the sum of the first <span class="process-math">\(n\)</span> term in the Fourier series. For our example, we have</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\begin{aligned}
y_1(x) &amp;=&amp; \frac{4}{\pi}\sin x\\
y_2(x) &amp;=&amp; \frac{4}{\pi}[\sin x+\frac{1}{3}\sin 3x]\\
y_3(x) &amp;=&amp; \frac{4}{\pi}[\sin x+\frac{1}{3}\sin 3x +\frac{1}{5}\sin 5x]\\
&amp;\cdots &amp;
\end{aligned}
\end{equation*}
</div>
<p class="continuation">Then, the limit <span class="process-math">\(\displaystyle\lim_{n\to\infty} y_n(x)\)</span> (if it converges) gives the whole Fourier series.</p>
<p id="p-343"></p>
<p id="p-344">Find the Fourier series for a periodic function <span class="process-math">\(f(x)\)</span> with period <span class="process-math">\(4\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
f(x)=\left\{\begin{array}{rl}0, &amp; \text{if~} -2&lt;x&lt;-1\\
K,  &amp; \text{if~} -1&lt;x&lt;1\\
0,&amp; \text{if~} 1&lt;x&lt;2\end{array}\right.,\qquad f(x+4)=f(x).
\end{equation*}
</div>
<p class="continuation">We use the Euler-Fourier formulas with <span class="process-math">\(L = 4/2=2\text{:}\)</span></p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
a_0=\frac{1}{2}\int_{-2}^{2} f(x)~ \textrm{d}x=\frac{1}{2}\cdot2\cdot\int_{0}^{1} K ~\textrm{d}x=K.
\end{equation*}
</div>
<p class="continuation">(or, <span class="process-math">\(f (x)\)</span> is even. Integrating <span class="process-math">\(f\)</span> over a period, one get twice of the integration over half of a period.)For <span class="process-math">\(n \geq 1\text{,}\)</span> we have</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\qquad\qquad\begin{aligned} a_n &amp;= \frac{1}{2}\int_{-2}^{2} f(x)\cos\frac{n\pi x}{2}\textrm{d}x\\
&amp;= \int_{0}^{2} f(x)\cos\frac{n\pi x}{2} \textrm{d}x\\
&amp;= \frac{2K}{n\pi}\sin\frac{n\pi x}{2}\Big|_{0}^{1}=\frac{2K}{n\pi}\sin\frac{n\pi}{2}.\end{aligned} \quad\text{i.e. } a_n=\left\{\begin{array}{ll}0, &amp; n\text{ even}\\
\frac{2K}{n\pi},&amp; n=1,5,9,\cdots\\
-\frac{2K}{n\pi}, &amp; n=3,7,11,\cdots .\end{array}\right.
\end{equation*}
</div>
<p class="continuation">(Both <span class="process-math">\(f (x)\)</span> and <span class="process-math">\(\cos\frac{n\pi x}{2}\)</span> are even. Then, the product <span class="process-math">\(f (x)\cos\frac{n\pi x}{2}\)</span> is even.)</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
b_n = \frac{1}{2}\int_{-2}^{2} f(x)\sin\frac{n\pi x}{2}\textrm{d}x=0.
\end{equation*}
</div>
<p class="continuation">(The product <span class="process-math">\(f (x)\sin\frac{n\pi x}{2}\)</span> is odd.)The Fourier series is</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
f(x)=\frac{K}{2}+\frac{2K}{\pi}\left[\cos\frac{\pi x}{2}-\frac{1}{3}\cos\frac{3\pi x}{2} +\frac{1}{5}\cos\frac{5\pi x}{2} -\frac{1}{7} \cos\frac{7\pi x}{2}+\cdots\right].
\end{equation*}
</div>
<p id="p-345"></p>
<p id="p-346">Next example is a dummy one, but might be useful.</p>
<p id="p-347">Find the Fourier coefficients for <span class="process-math">\(f(x)\text{,}\)</span> with period <span class="process-math">\(2\pi\text{,}\)</span> given as</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
f(x)=2+4\sin x-0.5\cos 4x -99\sin 100x.
\end{equation*}
</div>
<p class="continuation">Since <span class="process-math">\(f(x)\)</span> here is already in terms of sine and cosine functions, there is no need to compute the Fourier coefficients. We just need to figure out where each term would fit, by comparing it with a Fourier series. Only the following Fourier coefficients are nonzero:</p>
<div class="displaymath process-math" data-contains-math-knowls="">
\begin{equation*}
\frac{a_0}{2}=2,\quad b_1=4, \quad a_4=-0.5,\quad b_{100}=-99.
\end{equation*}
</div>
<ul id="p-348" class="disc">
<li id="li-35"><p id="p-349">If <span class="process-math">\(f(x)\)</span> is an odd function, then there are no cosine functions in the Fourier series.</p></li>
<li id="li-36"><p id="p-350">If <span class="process-math">\(f(x)\)</span> is an even function, then there are no sine functions in the Fourier series.</p></li>
</ul>
<p id="p-351">In the next section, we will verify this observation as a general rule.</p></section></div></main>
</div>
</body>
</html>
